fix(explorer): avoid holdings state updates during render#805
fix(explorer): avoid holdings state updates during render#805umeeSthein wants to merge 2 commits intotempoxyz:mainfrom
Conversation
|
i reproduced the holdings transition flicker on current @umeeSthein the render-time before/main repro: https://i.ibb.co/5WWzmJQj/pr805-full-repro.gif after/this PR repro: https://i.ibb.co/C5DV6mpg/pr805-after-fix.gif repro steps used:
so i think this PR fixes the unsafe render-time state updates, but not the visible stale holdings UI during address transitions. |
@o-az thanks for checking and for the repro. I agree this looks like a separate stale-data transition issue, not just the render-time I’ll try to reproduce this locally and update the PR. My first pass will be to avoid seeding the current address balances query with loader data from a previous address, roughly: const { address } = Route.useParams()
const { address: loaderAddress, balancesData } = Route.useLoaderData()
const currentBalancesData =
loaderAddress === address ? balancesData : undefinedThen the holdings view can stay in its default/loading state until balances for the new address are ready. |
@o-az pushed a follow-up for the stale holdings transition case. The change now only seeds the balances query from loader data when the loader address still matches the current route address. That should prevent the new address page from briefly rendering holdings data/page state from the previous address during client-side navigation. |
### motivation
The holdings view in the address route was mutating local state during render.
It reset holdings pagination and the show-all toggle when the address changed, and it also clamped the current holdings page during render when the visible asset count shrank. That makes the route fragile and can cause unnecessary rerenders or pagination flicker when holdings data changes asynchronously.
### implications
- move holdings reset-on-address-change into
React.useEffect- move holdings page clamping into
React.useEffect- render address transitions with the default holdings UI state immediately
- reuse the normalized holdings page count for both row slicing and the holdings footer